package com.hmall.search.web;

import com.hmall.common.dto.PageDTO;
import com.hmall.common.dto.SearchDTO;
import com.hmall.common.pojo.ItemDoc;
import com.hmall.common.pojo.SearchVo;
import com.hmall.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description SearchController
 * @Author zhq
 * @Date 2024-11-15
 */
@RestController
@RequestMapping("search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    /**
     * 过滤项聚合功能
     * @param dto
     * @return
     */
    @PostMapping("/filters")
    public SearchVo searchFilters(@RequestBody SearchDTO dto){
        return searchService.searchFilters();
    }

    @PostMapping("/list")
    public PageDTO<ItemDoc> searchList(@RequestBody SearchDTO dTO){
        return searchService.searchList(dTO);
    }
}
